﻿<%@ page language="java" import="com.newcrm.bean.*,com.newcrm.util.Util,com.newcrm.config.*,java.util.*" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
  // 获取产品信息
  ProductInfo productInfo = Config.getInstance().productInfo;

  String productName = productInfo.productName;
  String productId = productInfo.productId;
  String companyName = productInfo.companyName;
  String companyTel = productInfo.companyTel;
  String companyAddr = productInfo.companyAddress;
  String companyHref = productInfo.companyHref;
  String customerService = productInfo.customerService;
  String complainService = productInfo.complainService;

  /* 云通讯:0，云资讯:1 */
  User user = (User) session.getAttribute("user");

  Map<Integer, CompanyInfo> companys = (Map<Integer, CompanyInfo>) application.getAttribute(Const.APPLICATION_COMPANYS);
  CompanyInfo companyInfo = companys.get(Integer.valueOf(user.companyId));
  List<Map<String, Object>> taskCategory = companyInfo.taskCategorys;
  List<User> users = companyInfo.users;

  Object obj = session.getAttribute("voip");
  String voipAppID = "";
  String voipUserName = "";
  String voipUserPassword = "";
  String voipServerIP = "";
  String voipType = "";
  if (obj != null) {
    Map<String, Object> voip = (Map<String, Object>) obj;
    voipAppID = (String)voip.get("AppID");
    voipUserName = (String)voip.get("UserName");
    voipUserPassword = (String)voip.get("UserPwd");
    voipServerIP = (String)voip.get("ServerIP");
    voipType = (String)voip.get("VOIPType");
  }
  if (voipType == null || voipType.length() == 0) {
    voipType = "gateway";
  }
%>
<script language="JavaScript">
  var contextPath = "<%=request.getContextPath()%>";
  var allTaskCategory = new Array();
  <%if (taskCategory != null) {
      for (Map<String, Object> category:taskCategory) {
        String color = (String) category.get("Color");
        if (color == null || color.trim().length() == 0) {
          color = "000000";
        }
      %>
  allTaskCategory.push({id:"<%=category.get("TaskCategoryId")%>",name:"<%=Util.UEncode((String)category.get("TaskCategoryName"))%>", color:"<%=color%>"});
  <% }} %>
</script>
  <jsp:include page="callcenter.jsp" >
    <jsp:param name="voipServerIP" value="<%=Util.HTMLEncode(voipServerIP)%>" />
    <jsp:param name="voipType" value="<%=Util.HTMLEncode(voipType)%>" />
  </jsp:include>
  <div class="top-navi">
    <a class="close-menu" title="缩起左侧菜单" id="closeSidebar_link" href="#"><span></span></a>
    <div class="searchwrap"><span class="searchicon"><i class="fa fa-search fa-lg"></i></span><input type="text" id="top_sidebar_live_search" value="" name="term" title="输入关键字，快速查找客户" autocomplete="off"></div>
    <span class="phone_bar">
      <input type="text" id="phoneNumber" title="请输入电话号码"><a href="#" class="phoneCall green" v="0" id="phoneCall">呼叫</a>
    </span>
    <div class="popbox create-task-button">
      <a href="#" class="open button blue"><i class="fa fa-tasks"></i> 创建任务</a>
      <div class='collapse'>
        <div class='box'>
          <div class='arrow'></div><div class='arrow-border'></div>
          <form class="task" id="newTask">
            <h3>添加一个任务</h3>
            <p class="task_body">
              <input class="autofocus" id="taskTitle" size="25" type="text" />
            </p>
            <div>
              <h5>到期时间</h5>
              <p>
                <div class="datetimepicker_container"><input class="autofocus dueDate" id="taskDueDate" size="25" type="text" /></div>
              </p>
              <h5>任务负责人</h5>
              <p>
                <select id="taskResponsibleUserId" class="responsibleUserId">
                <option value="<%=user.userId%>">我</option>
                <%
                  String groupName = null;
                  for (User u : users) {
                    if (u.userId.equals(user.userId)) {
                      continue;
                    }

                    if (!companyInfo.isGroupAdmin(user, u.groupId)) {
                      continue;
                    }
                    String gn = companyInfo.getGroupName(u);
                    if (groupName == null) {
                      if (gn != null) {
                        groupName = gn;  %>
                  <optgroup label="<%=Util.HTMLEncode(groupName)%>">
               <%
                      }
                    } else {
                      if (!groupName.equals(gn)) {
                        groupName = gn; %>
                  </optgroup>
                  <optgroup label="<%=Util.HTMLEncode(groupName)%>">
               <%
                      }
                    }
                %>
                  <option value="<%=u.userId%>"><%=Util.HTMLEncode(u.name)%></option>
                <%}
                  if (groupName != null && groupName.length() > 0) { %>
                  </optgroup>
                <%}
                %>
                </select></p>
              <h5>任务分类</h5>
              <p>
                <select id="taskCategoryId" class="categoryId">
                <option value="0">无</option>
                <%for (Map<String, Object> cate:taskCategory) { %>
                <option value="<%=cate.get("TaskCategoryId")%>"><%=Util.HTMLEncode((String) cate.get("TaskCategoryName"))%></option>
                <%}%></select>
                <% if (user.isAdmin) {%>
                <a href="<%=request.getContextPath()%>/taskcategory" class="edit_categories">编辑分类</a>
                <% }%>
              </p>
              <p class="hide">
                <input class="checkbox" id="taskVisible" name="taskVisible" type="checkbox" value="1" />
                <label for="taskVisible">所有人可以看见这个任务</label>
              </p>
            </div>
            <div class="submit">
              <a id="add_task_button" class="button blue small closePopbox" href="#"><i class="fa fa-check"></i> 添加任务</a>
              &nbsp;&nbsp;<a href="#" class="closePopbox" id="add_task_cancel_link">取消</a>
            </div>
          </form>
        </div>
      </div>
    </div>
    <span class="create-button">
      <a href="<%=request.getContextPath()%>/company/new" class="button red"><i class="fa fa-user"></i> 创建客户</a>
    </span>
    <span class="alert-num" id="alertNum"></span>
    <span class="alert-button dropdown">
      <a class="dropdown-toggle" href="#" data-toggle="dropdown"><i class="fa fa-bell fa-2x"></i></a>
      <ul class="dropdown-menu pull-right">
        <li><p>您有 <strong id="totalNotificationNum"></strong> 条新的提醒</p></li>
        <li>
          <ul class="dropdown-menu-list">
            <li id="notification-contact"><a href="<%=request.getContextPath()%>/parties?nextDate=<%=Util.date2Str2(new Date())%>"><i class="fa fa-user fa-fw right"></i><span class="line"><strong>您有 <b id="contactNum"></b> 个客户需要联系</strong></span><span class="line small">截止日 今天</span></a></li>
            <li id="notification-task"><a href="<%=request.getContextPath()%>/task"><i class="fa fa-tasks fa-fw right"></i><span class="line"><strong>您有 <b id="taskNum"></b> 个需要处理的任务</strong></span><span class="line small">截止日 今天</span></a></li>
            <li id="notification-importantDate"><a href="<%=request.getContextPath()%>/importantDate"><i class="fa fa-bell fa-fw right"></i><span class="line"><strong>您有 <b id="importantDateNum"></b> 个需要处理的重要提醒</strong></span><span class="line small">截止日 今天</span></a></li>
          </ul>
        </li>
      </ul>
    </span>

    <span class="profile-info dropdown">
      <a class="dropdown-toggle" href="#" data-toggle="dropdown">系统设置 <i class="fa fa-caret-down"></i></a>
      <ul class="dropdown-menu pull-right">
        <li>
          <ul class="dropdown-menu-list">
            <li><a href="<%=request.getContextPath()%>/users/<%=user.userId%>/edit"><span class="line"><i class="fa fa-user"></i> <strong>个人信息</strong></span></a></li>
<% if (user.isAdmin) {%>
            <li><a href="<%=request.getContextPath()%>/groups"><span class="line"><i class="fa fa-sitemap"></i>  <strong>部门管理</strong></span></a></li>
            <li><a href="<%=request.getContextPath()%>/users"><span class="line"><i class="fa fa-users"></i> <strong>员工管理</strong></span></a></li>
            <li><a href="<%=request.getContextPath()%>/tag"><span class="line"><i class="fa fa-tag"></i> <strong>标签管理</strong></span></a></li>
            <li><a href="<%=request.getContextPath()%>/customercategory"><span class="line"><i class="fa fa-tag"></i> <strong>客户分类管理</strong></span></a></li>
            <li><a href="<%=request.getContextPath()%>/dealcategory"><span class="line"><i class="fa fa-rmb"></i> <strong>销售机会分类管理</strong></span></a></li>
            <li><a href="<%=request.getContextPath()%>/taskcategory"><span class="line"><i class="fa fa-tasks"></i> <strong>任务分类管理</strong></span></a></li>
            <li><a href="<%=request.getContextPath()%>/noteDefaultWord"><span class="line"><i class="fa fa-comment"></i> <strong>默认回复管理</strong></span></a></li>
            <li><a href="<%=request.getContextPath()%>/customerfield"><span class="line"><i class="fa fa-cogs"></i> <strong>客户自定义字段</strong></span></a></li>
            <li><a href="<%=request.getContextPath()%>/dealfield"><span class="line"><i class="fa fa-cogs"></i> <strong>销售机会自定义字段</strong></span></a></li>
            <li><a href="<%=request.getContextPath()%>/systemSetting"><span class="line"><i class="fa fa-cogs"></i> <strong>系统设置</strong></span></a></li>
<%}%>
<% if (!user.isAdmin && user.isGroupAdmin) {%>
            <li><a href="<%=request.getContextPath()%>/users"><span class="line"><i class="fa fa-users"></i> <strong>员工管理</strong></span></a></li>
<%}%>
            <!--
            <li><a href="<%=request.getContextPath()%>/voip/setting"><span class="line"><i class="fa fa-headphones"></i> <strong>呼叫中心后台管理</strong></span></a></li>
            -->
            <li><a class="open-popup-link" href="#about-popup"><span class="line"><i class="fa fa-trophy"></i> <strong>关于软件</strong></span></a></li>
            <li><a href="<%=request.getContextPath()%>/logout"><span class="line"><i class="fa fa-sign-out"></i> <strong>退出系统</strong></span></a></li>
          </ul>
        </li>
      </ul>
    </span>
  </div>
<%
  String sidebarUrl = "/sidebar";
%>
  <jsp:include flush="true" page="<%=sidebarUrl%>"></jsp:include>

  <div id="about-popup" class="white-popup mfp-hide">
    <div class="popup-title"><span class="title">关于</span> <span class="popup-close-button"><i class="fa fa-times"></i>&nbsp;</span></div>
    <div class="about">
      <div class="about-content">
          <div class="about-logo"><img src="<%=request.getContextPath()%>/images/<%=productId%>.png"></div>
          <div class="about-title"><%=productName%>客户管理系统(V <%=Const.VERSION%>)</div>
          <div class="about-desc">
            <p>新一代客户管理系统 (<a href='<%=companyHref%>' target="_blank"><%=companyHref%></a>)</p>
            <p><%=companyName%></p>
            <p>公司地址：<%=companyAddr%></p>
            <p>客服：<%=customerService%> 投诉：<%=complainService%></p>
          </div>
      </div>
      <div class="about-footer">
        <div class="right">电话：<%=companyTel%></div>
        <div>&copy;2010 - 2017 <a href='<%=companyHref%>' target="_blank"><%=productName%></a> Inc.</div>
      </div>
    </div>
  </div>
  <div id="app-popup" class="white-popup mfp-hide">
    <div class="popup-title"><span class="title">使用<%=productName%>H5手机版</span> <span class="popup-close-button"><i class="fa fa-times"></i>&nbsp;</span></div>
    <div class="about-content">
      <div class="about-title">手机版H5智享版实现移动办公</div>
      <div class="about-logo"><img src="<%=request.getContextPath()%>/images/<%=productId%>.png"></div>
      <div class="about-desc">
        <p>请使用手机浏览器访问美客宝系统地址</p>
        <p>统一用相关账号登录即可</p>
        <%--
        <p>具体操作参考 <a href='http://help.qikebao.com/posts/view/1074169/' target="_blank">H5手机版演示文档</a></p>
        --%>
      </div>
    </div>
  </div>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/balloon.js?ver=<%=Const.VERSION%>"></script>

  <input type="hidden" id="voipAppID" value="<%=Util.HTMLEncode(voipAppID)%>">
  <input type="hidden" id="voipUserName" value="<%=Util.HTMLEncode(voipUserName)%>">
  <input type="hidden" id="voipUserPassword" value="<%=Util.HTMLEncode(voipUserPassword)%>">
  <input type="hidden" id="voipType" value="<%=Util.HTMLEncode(voipType)%>">
  <input type="hidden" id="voipServerIP" value="<%=Util.HTMLEncode(voipServerIP)%>">
